<template>
	<view>
		<view class="mainpadding2">
			<template v-if="list.data.length==0">
				<view class="flexcolumn">
					<view class="placeholderimage" style="margin-top: 200rpx;"></view>
					<view class="xiaohei textcenter ershil">暂无数据</view>
				</view>
			</template>
			<template>
				<view class="mainpadding_top ffffff radius" v-for="item in list.data" :key="item.id">
					<view class="xiaohei ershiba fonweight titletext xiahuaxian" style="padding-bottom: 20rpx;">{{item.tourist.name}}</view>
					<view class="flexbetween margin_top2">
						<view class="xiaohong fonweight ershil">剩余次数：{{item.num}}次</view>
						<view class="listlanbtn strongtext margin_left3 xiaobai" @click="home">去使用</view>
						<!-- <view class="listlanbtn strongtext margin_left3 xiaobai" @click="jumpdetail('/pages/index/godetail?id=',item.tourist.id)">去使用</view> -->
					</view>
				</view>
			</template>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				page: 1,
				limit: 12,
				list: {
					data: []
				},
			}
		},
		onLoad() {
			this.init()
		},
		methods: {
			home(){
				uni.switchTab({
					url:"/pages/index/index"
				})
			},
			init(isPage, page) {
				let _this = this
				httpRequest.request('/api/user/touristUserNumIndex', 'GET', {
					page: page || 1,
					limit: 12,
				}).then(res => {
					uni.stopPullDownRefresh()
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data;
						}
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
		}
	}
</script>

<style>

</style>
